package com.yzf.demo.demo.DesignPattren.SingletonPattern.hungey;

/**
 * Created by 于占峰 on 2020/2/27/027.
 * 饿汉单例模式
 */
public class HungrySingleton {

/*    private static final HungrySingleton hungrySingleton = new HungrySingleton();

    private HungrySingleton() {
    }

    public HungrySingleton getInstans(){
        return hungrySingleton;
    }*/

    //装逼写法

    private static final HungrySingleton hungrySingleton;

    static {
        hungrySingleton = new HungrySingleton();
    }

    private HungrySingleton() {
    }

    ;

    public HungrySingleton getInstans() {
        return hungrySingleton;
    }
}
